feat(staged): hover parent-branch capsule to preview upstream commits#758
Conversation
Adds a `list_parent_branch_commits` Tauri command returning the
merge-base(HEAD, origin/{base})..origin/{base} commit range — the same
range powering the `+N` badge — and a `ParentBranchCommitsHover`
component that lazy-loads and renders it as a popover when the parent
capsule is hovered. The cache invalidates on `git-state-updated`.
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Stops the parent-branch capsule from showing a text I-beam on hover and restyles the popover header to "Upstream changes in <baseBranch>" so it doesn't just repeat the capsule label. Signed-off-by: Matt Toohey <contact@matttoohey.com>
If `git-state-updated` fired while `listParentBranchCommits` was in flight, the in-flight call saw a version mismatch and skipped clearing `loading` in `finally`, so every subsequent `loadCommits()` early- returned and the popover was stuck on "Loading…" until unmount. Wrap the fetch in a `while (open)` loop that transparently refetches on stale versions, and unconditionally clear `loading` in `finally`. Signed-off-by: Matt Toohey <contact@matttoohey.com>
`ParentBranchCommitsHover` is only mounted when `parentAheadCount > 0` (see `BranchCardHeaderInfo.svelte`), so the `count <= 0` early-return inside `scheduleOpen` can never fire. Remove the dead guard to match the rest of the file's trust-the-caller style. Signed-off-by: Matt Toohey <contact@matttoohey.com>
`list_parent_branch_commits` had no upper bound on either the workspace or worktree path, so a branch hundreds of commits behind its base would ship the full range across the IPC boundary even though the popover renders 25 rows + a `+N more` summary. Worse, on `merge-base` failure the bare `origin/<base>` revspec would walk to the root commit of the base branch. Add `--max-count=26` (MAX_ROWS + 1) on both paths to bound the payload and defang the fallback. Signed-off-by: Matt Toohey <contact@matttoohey.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 835b02b151
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| fn parse_parent_commit_lines(lines: &[String]) -> Vec<ParentBranchCommit> { | ||
| let mut commits = Vec::new(); | ||
| for line in lines { | ||
| let parts: Vec<&str> = line.splitn(6, '|').collect(); |
There was a problem hiding this comment.
Use a robust delimiter for parent commit parsing
When an upstream commit subject or author contains | (for example feat: add foo | bar), this parser shifts the remaining fields because git log --format=%H|%h|%s|%an|%ae|%ct does not escape that delimiter; the hover then shows the wrong author/email and usually a 0 timestamp. This affects only commits with that character, but those commit subjects are valid and will make the new preview misleading; use a NUL/record separator or parse a format with unambiguous delimiters.
Useful? React with 👍 / 👎.
Summary
Adds a hover popover on the parent-branch capsule that previews the upstream commits powering the
+Nbadge (merge-base(HEAD, origin/{base})..origin/{base}).list_parent_branch_commitsTauri command that returns the same range as the badge count, capped at 26 rows (MAX_ROWS + 1) on both workspace and worktree paths to bound the IPC payload and defang theorigin/<base>fallback ifmerge-basefails.ParentBranchCommitsHoverSvelte component that lazy-loads the range on hover, renders up to 25 rows + a+N moresummary, and invalidates ongit-state-updated.git-state-updatedfires mid-fetch, the in-flight call would previously leaveloadingset forever; now we loop while open and always clearloadinginfinally.Test plan
+N > 0; verify the popover lists the same upstream commits.git-state-updated(e.g. fetch) while the popover is open; verify it refreshes instead of getting stuck on "Loading…".